// components/auth/index.js
Component({
  data: {
    isLogin: false,
  },
  lifetimes: {
    attached() {
      const app = getApp()
      const isLogin = Boolean(app.token)
      this.setData({
        isLogin,
      })

      if (isLogin === false) {
        // 页面回跳
        const pages = getCurrentPages()
        // const {route} = pages[pages.length -1]
        const page = pages.pop()
        page.onLoad = () => {}
        page.onShow = () => {}
        wx.redirectTo({
          url: '/pages/login/index?redirectUrl=/' + page.route,
        })
      }
    },
  },
})
